import com.trivia.administration.Role
import com.trivia.administration.User
import com.trivia.administration.UserRole

class BootStrap {

    def springSecurityService

    def init = { servletContext ->
        def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)

        String password = springSecurityService.encodePassword('admin')
        def testUser = new User(username: 'admin', enabled: true, password: password, email:"nicolasmagaldi@gmail.com")
        testUser.save(flush: true)
		
        UserRole.create testUser, adminRole, true
    }

    def destroy = {

    }
}
